package com.sky.task;

import com.sky.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

//@Component
public class WebSocketTask {

    @Autowired
    private WebSocketServer webSocketServerl;

    /**
     * 通过WebSocket每隔5秒向客户端发送消息
     */
    public void sendMessageToClient(){
        webSocketServerl.sendToAllClient("\"这是来自服务端的消息：\" + DateTimeFormatter.ofPattern(\"HH:mm:ss\").format(LocalDateTime.now())");
    }
}
